Skip to content

digest and hmac: drop intermediate builder and directly take slices for input#766

Open
Tpt wants to merge 2 commits into
apache:mainfrom
Tpt:tpt/hmac-digest
Open

digest and hmac: drop intermediate builder and directly take slices for input#766
Tpt wants to merge 2 commits into
apache:mainfrom
Tpt:tpt/hmac-digest

Conversation

@Tpt

@Tpt Tpt commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

It removes the need for intermediate traits.

All callers can easily build a slice of slices but the S3 object content SHA 256 computation that is expensive anyway.

Follow up to #707

…or input

It removes the need for intermediate traits.

All callers can easily build a slice of slices but the S3 object content SHA 256 computation that is expensive anyway.
@Tpt Tpt force-pushed the tpt/hmac-digest branch from 70a1be9 to 33e4f3f Compare June 18, 2026 15:27
Comment thread src/client/crypto.rs Outdated
Co-authored-by: Kevin Liu <kevinjqliu@users.noreply.github.com>

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Tpt and @kevinjqliu

Comment thread src/client/crypto.rs
/// Finalizes the digest calculation and returns the digest value.
///
/// It is implementation-defined behaviour to call this after calling [`Self::finish`]
fn finish(&mut self) -> Result<&[u8]>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could possibly have a smaller API change and just allow the traits to return a Vec directly 🤔 that would also avoid the need for a copy in some cases and might be a smaller API change?

fn build(self) -> Result<Vec<u8>> { 
...
}

@Tpt Tpt Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review!

All digests are currently stored in fixed length arrays so it would not save any allocation in our case, just a possible memcopy at the cost of maybe a useless allocations.

On the breaking changes, I hoped that this changed would be reviewed before the release, seems it's not the case sadly. I just found quite sad to have a complicated API with a lot of dynamic traits where a smaller API could work. Feel free to close this MR.

@kevinjqliu

kevinjqliu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

btw ci issue is from docker failing

Unable to find image 'amazon/amazon-ec2-metadata-mock:v1.9.2' locally
docker: Error response from daemon: Head "https://registry-1.docker.io/v2/amazon/amazon-ec2-metadata-mock/manifests/v1.9.2": Get "https://auth.docker.io/token?account=githubactions&scope=repository%3Aamazon%2Famazon-ec2-metadata-mock%3Apull&service=registry.docker.io": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

EDIT: #776 should fix this going forward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants